<?php
class Log extends Base
{
    protected function getPrimaryKey()
    {
        return "logId";
    }

    protected function getTableName()
    {
        return "log";
    }

    public function isIpExist($operatorId, $ip, $logType)
    {
        $sql = "select count(1) as count from log where type ='" . $logType . "' and ip='" . $ip . "' and operator_id='" . $operatorId . "'";
        $count = $this->_db->getone($sql);
        return count($count) > 0 && $count['count'] > 0;
    }

    public function insert($operatorId, $operatedId, $ip, $logType)
    {
        $sql = "insert into log (type,ip,operator_id,operated_id,createDate) values ('" . $logType . "','" . $ip . "','" . $operatorId . "','" . $operatedId . "','" . Util::getCurrentDate() . "')";
        $this->_db->query($sql);
    }
}

?>